package hot_100;

import java.util.ArrayList;
import java.util.List;

public class 二叉树的中序遍历 {
    public static void main(String[] args) {

    }

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    List<Integer> ans = new ArrayList<>();

    public List<Integer> inorderTraversal(TreeNode root) {
        Dfs(root);
        return ans;
    }

    public void Dfs(TreeNode root) {
        if (root == null)
            return;
        inorderTraversal(root.left);
        ans.add(root.val);
        inorderTraversal(root.right);
    }
}
